<!--
 * @Author         : yanyongyu
 * @Date           : 2022-09-22 03:25:56
 * @LastEditors    : yanyongyu
 * @LastEditTime   : 2022-10-17 12:20:25
 * @Description    : None
 * @GitHub         : https://github.com/yanyongyu
-->

{% from "icons/cross-reference.html.jinja" import octicon_cross_reference %}
{% from "components/issue/state.html.jinja" import issue_state %}
{% from "components/pr/state.html.jinja" import pr_state %}

{% macro cross_referenced(event, ns) %}
{% set repo = get_issue_repo(ns.issue) %}
<div class="TimelineItem">
  <div class="TimelineItem-badge">
    {{ octicon_cross_reference() }}
  </div>
  <div class="TimelineItem-body">
    <div>
      <a class="d-inline-block">
        <img class="avatar avatar-user" height="20" width="20" src="{{ event.actor.avatar_url }}" />
      </a>
      <a href="#" class="Link--primary text-bold">{{ event.actor.login|escape }}</a>
      mentioned this
      {% if ns.issue.pull_request %}
      pull request
      {% else %}
      issue
      {% endif %}
      {{ event.created_at|relative_time }}
    </div>
    <div class="mt-2 d-flex flex-items-start flex-column flex-md-row">
      <div class="flex-auto wb-break-word">
        <a href="#" class="Link--primary f4 text-bold markdown-title">
          {{ event.source.issue.title|markdown_title }}
          <span class="color-fg-muted text-normal">
            {% if event.source.issue.repository.full_name == repo.full_name %}
            {{ '#' ~ event.source.issue.number }}
            {% else %}
            {{ event.source.issue.repository.full_name|escape ~ '#' ~ event.source.issue.number }}
            {% endif %}
          </span>
        </a>
      </div>
      {% if event.source.issue.pull_request %}
      {{ pr_state(get_pull_request(event.source.issue), "flex-shrink-0 my-1 my-md-0 ml-md-3")}}
      {% else %}
      {{ issue_state(event.source.issue, "flex-shrink-0 my-1 my-md-0 ml-md-3") }}
      {% endif %}
    </div>
  </div>
</div>
{% endmacro %}
